* with the column at that point. @cell_x and @cell_y return the coordinates
* relative to the cell background (i.e. the @background_area passed to
* gtk_cell_renderer_render()). This function is only meaningful if
- * @tree_view is realized.
+ * @tree_view is realized. Therefore this function will always return %FALSE
+ * if @tree_view is not realized or does not have a model.
*
* For converting widget coordinates (eg. the ones you get from
* GtkWidget::query-tooltip), please see
gint y_offset;
g_return_val_if_fail (tree_view != NULL, FALSE);
- g_return_val_if_fail (tree_view->priv->bin_window != NULL, FALSE);
if (path)
*path = NULL;
if (column)
*column = NULL;
+ if (tree_view->priv->bin_window == NULL)
+ return FALSE;
+
if (tree_view->priv->tree == NULL)
return FALSE;
* @pos: Return location for the drop position, or %NULL
*
* Determines the destination row for a given position. @drag_x and
- * @drag_y are expected to be in widget coordinates.
+ * @drag_y are expected to be in widget coordinates. This function is only
+ * meaningful if @tree_view is realized. Therefore this function will always
+ * return %FALSE if @tree_view is not realized or does not have a model.
*
- * Return value: whether there is a row at the given position.
+ * Return value: whether there is a row at the given position, %TRUE if this
+ * is indeed the case.
**/
gboolean
gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
g_return_val_if_fail (tree_view != NULL, FALSE);
g_return_val_if_fail (drag_x >= 0, FALSE);
g_return_val_if_fail (drag_y >= 0, FALSE);
- g_return_val_if_fail (tree_view->priv->bin_window != NULL, FALSE);
-
if (path)
*path = NULL;
+ if (tree_view->priv->bin_window == NULL)
+ return FALSE;
+
if (tree_view->priv->tree == NULL)
return FALSE;
gtk_tree_path_free (path);
}
+static void
+test_bug_539377 (void)
+{
+ GtkWidget *view;
+ GtkTreePath *path;
+ GtkListStore *list_store;
+
+ /* Test provided by Bjorn Lindqvist */
+
+ /* Non-realized view, no model */
+ view = gtk_tree_view_new ();
+ g_assert (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), 10, 10, &path,
+ NULL, NULL, NULL) == FALSE);
+ g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10,
+ &path, NULL) == FALSE);
+
+ /* Non-realized view, with model */
+ list_store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view),
+ GTK_TREE_MODEL (list_store));
+
+ g_assert (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), 10, 10, &path,
+ NULL, NULL, NULL) == FALSE);
+ g_assert (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), 10, 10,
+ &path, NULL) == FALSE);
+}
+
int
main (int argc,
char **argv)
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/TreeView/cursor/bug-546005", test_bug_546005);
+ g_test_add_func ("/TreeView/cursor/bug-539377", test_bug_539377);
return g_test_run ();
}